﻿using PLCTest.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PLCTest.BO
{
    public class ZJNScMessageWcsActionBO
    {

        /// <summary>
        /// 启动命令
        /// </summary>
        public bool Startcommand { get; set; }
        /// <summary>
        /// 报警复位
        /// </summary>
        public bool Alarmreset { get; set; }
        /// <summary>
        /// 自动任务复位
        /// </summary>
        public bool Taskreset { get; set; }
        /// <summary>
        /// WCS消防命令
        /// </summary>
        public bool WCSfirecommand { get; set; }

        /// <summary>
        /// WCS拍照温度无异常
        /// </summary>
        public bool WCSPhotoFire { get; set; }

        /// <summary>
        /// WCS拍照温度异常堆垛机救火
        /// </summary>
        public bool WCSRgvFireHlper { get; set; }

        /// <summary>
        /// DTS有温度报警但红外摄像仪拍照无异常，请人工检查
        /// </summary>
        public bool WCSDTSAlarm { get; set; }

        /// <summary>
        /// 手动任务复位
        /// </summary>
        public bool TimeReset { get; set; }
        /// <summary>
        /// 工作序号
        /// </summary>
        public int Jobnumber { get; set; }
        /// <summary>
        /// 工作命令代码
        /// </summary>
        public short Jobordercode { get; set; }
        /// <summary>
        /// 启始行fromPC
        /// </summary>
        public short StartlinefromPC { get; set; }
        /// <summary>
        /// 启始列fromPC
        /// </summary>
        public short StartcolumnfromPC { get; set; }
        /// <summary>
        /// 启始层fromPC
        /// </summary>
        public short StartlayerfromPC { get; set; }
        /// <summary>
        /// 目标行fromPC
        /// </summary>
        public short TargetlinefromPC { get; set; }
        /// <summary>
        /// 目标列fromPC
        /// </summary>
        public short TargetcolumnfromPC { get; set; }
        /// <summary>
        /// 目标层fromPC
        /// </summary>
        public short TargetlayerfromPC { get; set; }
        /// <summary>
        /// WCS过账完成
        /// </summary>
        public short WCSpostingcompleted { get; set; }
        /// <summary>
        /// 托盘类型 1：大托盘   2：小托盘
        /// </summary>
        public short yuliu8 { get; set; }
        public short yuliu9 { get; set; }
        public short yuliu10 { get; set; }
        public short yuliu11 { get; set; }
        public short yuliu12 { get; set; }

        ///// <summary>
        ///// RGV-PC消防水箱处请求放料
        ///// </summary>
        //public bool RgvRequsetPush { get; set; }
        ///// <summary>
        ///// RGV-PC消防水箱处放料完成
        ///// </summary>
        //public bool RgvPushFinish { get; set; }
        ///// <summary>
        ///// PC-RGV消防水箱处允许放料
        ///// </summary>
        //public bool RgvCanPush { get; set; }
        ///// <summary>
        ///// 开机时间
        ///// </summary>
        //public int StartTime { get; set; }
        ///// <summary>
        ///// 手动时间
        ///// </summary>
        //public int HandTime { get; set; }
        ///// <summary>
        ///// 手动故障时间
        ///// </summary>
        //public int HandHitchTime { get; set; }
        ///// <summary>
        ///// 自动运行时间
        ///// </summary>
        //public int AutoRuningTime { get; set; }
        ///// <summary>
        ///// 自动待机时间
        ///// </summary>
        //public int AutoWaitingTime { get; set; }
        ///// <summary>
        ///// 自动故障时间
        ///// </summary>
        //public int AutoHitchTime { get; set; }
        ///// <summary>
        ///// 任务运行时间
        ///// </summary>
        //public int TaskRuningTime { get; set; }



        public void Serialize(byte[] bytes)
        {
            //PlcConnectionID = plcConnectionID;
            //PlcReadDbID = plcReadDbID;
            //BytesIndex = bytesIndex;
            //BytesLength = bytesLength;
            //ObjectIndex = objectIndex;
            //ObjectLength = objectLength;
            ///// <summary>
            ///// 约定：
            ///// 1、设备状态报文以State结尾；
            ///// 2、Plc的动作报文以PlcAction结尾；
            ///// 3、Wcs的动作报文以WcsAction结尾；
            ///// 4、平面PLC报文统一PlcState名称
            ///// （后续有其他的再约定）
            ///// </summary>
            //ObjectType = objectType;
            //EquipmentCode = ScEquipmentCode;

            Startcommand = HelperByte.GetBitAt(bytes, 0, 0);
            Alarmreset = HelperByte.GetBitAt(bytes, 0, 1);
            Taskreset = HelperByte.GetBitAt(bytes, 0, 2);
            WCSfirecommand = HelperByte.GetBitAt(bytes, 0, 3);
            WCSPhotoFire = HelperByte.GetBitAt(bytes, 0, 4);
            WCSRgvFireHlper = HelperByte.GetBitAt(bytes, 0, 5);
            WCSDTSAlarm = HelperByte.GetBitAt(bytes, 0, 6);
            TimeReset = HelperByte.GetBitAt(bytes, 0, 7);

            Jobnumber = HelperByte.GetDIntAt(bytes, 2);
            Jobordercode = HelperByte.GetIntAt(bytes, 6);
            StartlinefromPC = HelperByte.GetIntAt(bytes, 8);
            StartcolumnfromPC = HelperByte.GetIntAt(bytes, 10);
            StartlayerfromPC = HelperByte.GetIntAt(bytes, 12);
            TargetlinefromPC = HelperByte.GetIntAt(bytes, 14);
            TargetcolumnfromPC = HelperByte.GetIntAt(bytes, 16);
            TargetlayerfromPC = HelperByte.GetIntAt(bytes, 18);
            WCSpostingcompleted = HelperByte.GetIntAt(bytes, 20);
            yuliu8 = HelperByte.GetIntAt(bytes, 22);
            yuliu9 = HelperByte.GetIntAt(bytes, 24);
            yuliu10 = HelperByte.GetIntAt(bytes, 26);
            yuliu11 = HelperByte.GetIntAt(bytes, 28);
            yuliu12 = HelperByte.GetIntAt(bytes, 30);

            //RgvRequsetPush = HelperByte.GetBitAt(bytes, 32, 0);
            //RgvPushFinish = HelperByte.GetBitAt(bytes, 32, 1);
            //RgvCanPush = HelperByte.GetBitAt(bytes, 32, 2);
            //StartTime = HelperByte.GetDIntAt(bytes, 34);
            //HandTime = HelperByte.GetDIntAt(bytes, 38);
            //HandHitchTime = HelperByte.GetDIntAt(bytes, 42);
            //AutoRuningTime = HelperByte.GetDIntAt(bytes, 46);
            //AutoWaitingTime = HelperByte.GetDIntAt(bytes, 50);
            //AutoHitchTime = HelperByte.GetDIntAt(bytes, 54);
            //TaskRuningTime = HelperByte.GetDIntAt(bytes, 58);
        }

    }
}
